package com.qfedu.dao;

import com.qfedu.entity.Usergroup;
import com.qfedu.entity.Usergroup;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * projectName: logistics
 * author: CGY
 * time: 2020/10/9 20:55
 * description:
 */
@Repository
public interface UsergroupDao extends JpaRepository<Usergroup,Long> {

    @Query(value = "select ug.* from  usergroup ug join userwithgroup uwg " +
            " on ug.id = uwg.group_id where uwg.user_id = ?1",nativeQuery = true)
    Usergroup selectUsergroupByUserId(String userId);

    List<Usergroup> findAll();

    Usergroup save(Usergroup usergroup);

    Usergroup findUsergroupById(Long groupId);

    Integer deleteUsergroupById(Long id);
}


